package com.codinghero.example.jdk.lock.reetrantrw;

import com.codinghero.util.NumberUtils;

/**
 * The example shows that read lock simultaneously and write lock serially.
 * 
 * @author liutong
 * 
 */
public class ReadWriteLockExample {

	public static void main(String[] args) {
		
		for (int i = 0; i < 20; i++) {
			Thread t = null;
			int random = NumberUtils.randomInt(2);
			if (random == 0) {
				t = new Thread(new ReadOper());
				t.start();
			} else {
				t = new Thread(new WriteOper());
				t.start();
			}
		}
	}

}
